package com.dime.physical.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.dime.physical.domain.dto.CompanyDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.dime.physical.domain.DimeBasecompany;
import com.dime.physical.service.IDimeBasecompanyService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 体检单位管理Controller
 * 
 * @author Tiny
 * @date 2023-09-14
 */
@RestController
@RequestMapping("/basecompany")
public class DimeBasecompanyController extends BaseController
{
    @Autowired
    private IDimeBasecompanyService dimeBasecompanyService;

    /**
     * 查询体检单位管理列表
     */
    @RequiresPermissions("physical:basecompany:list")
    @GetMapping("/list")
    public TableDataInfo list(DimeBasecompany dimeBasecompany)
    {
        startPage();
        List<DimeBasecompany> list = dimeBasecompanyService.selectDimeBasecompanyList(dimeBasecompany);
        return getDataTable(list);
    }

    /**
     * 导出体检单位管理列表
     */
    @RequiresPermissions("physical:basecompany:export")
    @Log(title = "体检单位管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DimeBasecompany dimeBasecompany)
    {
        List<DimeBasecompany> list = dimeBasecompanyService.selectDimeBasecompanyList(dimeBasecompany);
        ExcelUtil<DimeBasecompany> util = new ExcelUtil<DimeBasecompany>(DimeBasecompany.class);
        util.exportExcel(response, list, "体检单位管理数据");
    }

    /**
     * 获取体检单位管理详细信息
     */
    @RequiresPermissions("physical:basecompany:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(dimeBasecompanyService.selectDimeBasecompanyById(id));
    }

    /**
     * 新增体检单位管理
     */
    @RequiresPermissions("physical:basecompany:add")
    @Log(title = "体检单位管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DimeBasecompany dimeBasecompany)
    {
        return toAjax(dimeBasecompanyService.insertDimeBasecompany(dimeBasecompany));
    }

    /**
     * 修改体检单位管理
     */
    @RequiresPermissions("physical:basecompany:edit")
    @Log(title = "体检单位管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DimeBasecompany dimeBasecompany)
    {
        return toAjax(dimeBasecompanyService.updateDimeBasecompany(dimeBasecompany));
    }

    /**
     * 删除体检单位管理
     */
    @RequiresPermissions("physical:basecompany:remove")
    @Log(title = "体检单位管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dimeBasecompanyService.deleteDimeBasecompanyByIds(ids));
    }


    @RequiresPermissions("physical:basecompany:getBQCompany")
    @Log(title = "获取扁鹊订单信息", businessType = BusinessType.OTHER)
    @GetMapping("/getBQCompany/{SOANo}")
    public AjaxResult getBQCompany(@PathVariable String SOANo)
    {
        return success(dimeBasecompanyService.getBqCompanyBySoaNo(SOANo));
    }


    @RequiresPermissions("physical:basecompany:saveBQCompany")
    @Log(title = "保存订单信息", businessType = BusinessType.OTHER)
    @PostMapping("/saveBQCompany")
    public AjaxResult saveBQCompany(@RequestBody CompanyDto companyDto)
    {
        return toAjax(dimeBasecompanyService.saveCompany(companyDto));
    }


    @RequiresPermissions("physical:basecompany:editSearchBQCompany")
    @Log(title = "查询单位", businessType = BusinessType.OTHER)
    @PostMapping("/editSearchBQCompany")
    public AjaxResult editSearchBQCompany(@RequestBody DimeBasecompany  basecompany)
    {
        return success(dimeBasecompanyService.editSearchBQCompany(basecompany));
    }


    @RequiresPermissions("physical:basecompany:editSearchBQCompany")
    @Log(title = "查询单位", businessType = BusinessType.OTHER)
    @PostMapping("/editSearchBQCompany/{id}")
    public AjaxResult editSearchBQCompanyById(@PathVariable("id") String id)
    {
        return success(dimeBasecompanyService.editSearchBQCompanyById(id));
    }


    @RequiresPermissions("physical:basecompany:editSaveBQCompany")
    @Log(title = "修改保存单位", businessType = BusinessType.OTHER)
    @PostMapping("/editSaveBQCompany")
    public AjaxResult editSaveBQCompany(@RequestBody CompanyDto companyDto)
    {
        return toAjax(dimeBasecompanyService.editSaveBQCompany(companyDto));
    }
}
